package model;

import java.util.ArrayList;


/**
 * This File represents a data node for the given example and has only getterMethods for the variables.
 * @author walonka
 * @version 1.0
 *
 */
public class AIDataNode {
	private ArrayList<Double> data;
	private ArrayList<AIDataNode> nearestNeighborRef;
	private String klass;

	public AIDataNode(double[] input, String klass){
		data = new ArrayList<Double>();
		for(int i=0; i<input.length; i++){
			data.add(input[i]);
		}
		this.klass=klass;
		nearestNeighborRef = new ArrayList<AIDataNode>();
	}

	
	/**
	 * Gives access by Reference to the ArrayList holding the k nearest neighbors of the node.
	 * @return Reference to the nearest neighbor arraylist
	 */
	public ArrayList<AIDataNode> getNearestNeighborRef(){
		return this.nearestNeighborRef;
	}
	public void addNearestNeighbor(AIDataNode node){
		this.nearestNeighborRef.add(node);
	}


	public double getKlass() {
		if (klass.equals("class1")){
			return 1;
		}
		return 0;
	}
	
	/**
	 * Return an array of all the stored data num_pregnant,Plasma_conc,blood_pres,triceps,insulin,BMI,pedigree,age
	 * @return num_pregnant,Plasma_conc,blood_pres,triceps,insulin,BMI,pedigree,age
	 */
	public double[] getNodeWeight(){
		double[] tmp = new double[data.size()];
		for(int i=0; i<data.size();i++){
			tmp[i]=data.get(i);
		}
		return tmp;
	}
	
	public String toString(){
		String tmp ="";
		for(int i=0; i<data.size();i++){
			tmp+=data.get(i)+",";
		}
		tmp+=klass;
		return tmp;
	}
	
	
	
}
